package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportExpenseDetail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 15:59:37
 */
@Repository
public class TransportExpenseDetailDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportExpenseDetailDao.class);

    public TransportExpenseDetail insert(final TransportExpenseDetail transportExpenseDetail) {
        insert("TransportExpenseDetail.insert", transportExpenseDetail);
        return transportExpenseDetail;
    }

    public List<TransportExpenseDetail> insertForBatch(final List<TransportExpenseDetail> batchList) {
        insert("TransportExpenseDetail.insertForBatch", batchList);
        return batchList;
    }

    public Boolean updateInfoById(final TransportExpenseDetail transportExpenseDetail) {
        return update("TransportExpenseDetail.updateInfoById", transportExpenseDetail) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportExpenseDetail.updateInfoByQuery", query) > 0;
    }

    public TransportExpenseDetail selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportExpenseDetail.selectById", query);
    }

    public List<TransportExpenseDetail> selectByQuery(final Query query) {
        return queryForList("TransportExpenseDetail.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportExpenseDetail.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        //TransportExpenseDetail transportExpenseDetail = new TransportExpenseDetail();
        //transportExpenseDetail.setDeleteFlag(1);
        //transportExpenseDetail.setId(id);
        //transportExpenseDetail.setEntId(entId);

        //return update("TransportExpenseDetail.updateInfoById", transportExpenseDetail) > 0;
        return false;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportExpenseDetail.deleteById", query) > 0;
    }
}